﻿//++
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
// Module Name:
//
//  NotificationCondition.cs
//    
// Abstract:
//
//  This abstract class represent the base class from which subclasses are defined for 
//  the conditions on Notification rules.
//  
//--

using System;
using System.Diagnostics;

namespace Microsoft.EnhancedReminders
{
    /// <summary>
    /// Abstract condition class for encapsulating Notification rules conditions
    /// </summary>
    [Serializable()]
    public abstract class NotificationCondition
    {
        /// <summary>
        /// Indicate if this condition is selected
        /// </summary>
        private bool _isSelected;

        /// <summary>
        /// Constructor.
        /// </summary>
        protected NotificationCondition()
        { 
        }

        /// <summary>
        /// Copy constructor.
        /// </summary>
        protected NotificationCondition(NotificationCondition condition)
        {
            Debug.Assert(condition != null, "condition");

            _isSelected = condition._isSelected;
        }

        /// <summary>
        /// Determines if this time condition equals the specified condition.
        /// </summary>
        /// <param name="condition">Condition to compare against</param>
        /// <returns>
        /// true if the conditions are equivalent; false otherwise
        /// </returns>
        public virtual bool Equals(NotificationCondition condition)
        {
            Debug.Assert(condition != null, "condition != null");

            return _isSelected == condition._isSelected;
        }

        /// <summary>
        /// Determines if this condition matches the specified data.
        /// </summary>
        /// <param name="notificationData">Data</param>
        /// <returns>
        /// true if the condition matches the conditions; false otherwise.
        /// </returns>
        public abstract bool IsSatisfied(INotificationData notificationData);

        /// <summary>
        /// Flag to indicate if this condition is selected
        /// </summary>
        public bool IsSelected
        {
            get
            {
                return _isSelected;
            }
            set
            {
                _isSelected = value;
            }
        }
    }
}
